package com.cspg.ssss.controller;

import com.cspg.ssss.domain.ScoreDetailedTotalVO;
import com.cspg.ssss.domain.ScoreDetailedVO;
import com.cspg.ssss.domain.ScoreVO;
import com.cspg.ssss.service.ScoreStatisticsService;
import com.cspg.ssss.vo.ResultVo;
import com.cspg.ssss.vo.ResultVoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 问题打分统计后台接口
 *
 * @author yanbq
 * @since 2021-06-17
 */
@RestController
@RequestMapping("/statistics")
public class ScoreStatisticsController {

    @Autowired
    private ScoreStatisticsService scoreStatisticsService;

    /**
     * year : 年份
     * type : 0=公司，1单位
     * dwmc ：单位名称
     */
    @PostMapping(value = "/selectScoreList")
    public ResultVo selectScoreList(@RequestBody Map<String, Object> map) {
        List<ScoreVO> list = scoreStatisticsService.selectScoreList(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    /**
     * year : 年份
     * dwmc ：单位名称
     * time_type:0-整年，1-上半年，2-下半年
     */
    @PostMapping(value = "/selectDetailedTotalList")
    public ResultVo selectDetailedTotalList(@RequestBody Map<String, Object> map) {
        List<ScoreDetailedTotalVO> list = scoreStatisticsService.selectDetailedTotalList(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    /**
     * khbm : 评分部门
     * username：评分人
     * year：年份
     * time_type:0-整年，1-上半年，2-下半年
     * score_type:0-扣分,1-加分
     * check_type:0
     * bmmc:部门名称
     */
    @PostMapping(value = "/scoreGsDetailedList")
    public ResultVo scoreGsDetailedList(@RequestBody Map<String, Object> map) {
        List<ScoreDetailedVO> list = scoreStatisticsService.scoreGsDetailedList(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    /**
     * khbm : 评分部门
     * username：评分人
     * year：年份
     * bmmc:部门名称
     * check_type:1
     */
    @PostMapping(value = "/scoreDwDetailedList")
    public ResultVo scoreDwDetailedList(@RequestBody Map<String, Object> map) {
        List<ScoreDetailedVO> list = scoreStatisticsService.scoreDwDetailedList(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    /**
     * scoreDeptList : 评分部门
     * year：年份
     * type : 0=公司，1单位
     * bmmc:部门名称
     */
    @PostMapping(value = "/scoreDeptList")
    public ResultVo scoreDeptList(@RequestBody Map<String, Object> map) {
        List<String> list = scoreStatisticsService.scoreDeptList(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }


    @GetMapping(value = "/test")
    public ResultVo test() {
        scoreStatisticsService.updateScoreStatisticsList(0);
        scoreStatisticsService.updateScoreStatisticsList(1);
        return ResultVoUtil.success("查询成功", null);
    }

}
